package com.aiks.dsyncpluginspringbootautoconfigure;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 * 静态获取spring上下文对象..
 *
 * @author <a href="mailto:aiks_yuan@163.com">yuanz</a>
 * @date 2022-07-20 9:58 上午
 * @since 1.0.0
 **/
public class SpringContext implements ApplicationContextAware {

    private static ApplicationContext context;

    /**
     * aware context.
     *
     * @param applicationContext context
     * @throws BeansException beanexception
     */
    @Override
    public void setApplicationContext(final ApplicationContext applicationContext) throws BeansException {
        context = applicationContext;
    }

    /**
     * global applicationContext.
     *
     * @return applicationContext
     */
    public static ApplicationContext getAppContext() {
        return context;
    }
}
